package com.lingnan.tijian.controller;

import com.lingnan.tijian.domain.User;
import com.lingnan.tijian.domain.dto.UserLoginDTO;
import com.lingnan.tijian.domain.result.Result;
import com.lingnan.tijian.domain.vo.UserLoginVO;
import com.lingnan.tijian.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 无Controller
 * 
 * @author manba
 * @date 2024-12-26
 */
@RestController
@RequestMapping()
@Slf4j
public class UserController
{
    @Autowired
    private IUserService userService;

    /**
     * 用户登录
     * @param userLoginDTO
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody UserLoginDTO userLoginDTO){
        log.info("用户登录:{}",userLoginDTO);
        UserLoginVO userLoginVO = userService.login(userLoginDTO);
        return Result.success(userLoginVO);
    }

    /**
     * 注册
     * @return
     */
    @PostMapping("/register")
    public Result insert(@RequestBody User user){
        log.info("用户注册:{}",user);
        userService.insertUser(user);
        return Result.success();
    }

    @GetMapping("/user/info")
    public Result selectUserById(){
        User user = userService.selectUserById();
        return Result.success(user);
    }

}
